#!/usr/bin/env node

let buf1=Buffer.alloc(256);
buf1[0]=[0];
console.log(buf1.length);
console.log('\n',buf1);

for(let i=0; i<buf1.length; i++){
  buf1[i]=i;
}
console.log('\n',buf1);

let buf2=buf1.slice(247,256);
console.log('\n',buf2);

buf2.fill(0);
console.log('\n',buf2);
console.log('\n',buf2.toJSON());
console.log( JSON.stringify(buf2));

let arr=[1,2,3,4,5];
let buf3  = Buffer.from(arr);
console.log('\n', buf3.length, buf3);

let buf4 = Buffer.from('hello world', 'utf8');
console.log('\n', buf4.length, buf4);

buf4.copy(buf3, 0, 0, buf3.length);
console.log('\n', buf3.length, buf3);

let str = 'abc';
let buf5 = Buffer.from(str, 'utf8');
console.log('\nbuf5.length:', buf5.length);
console.log('\nbuffer5:', buf5);
console.log('\nstr:', str.length);

